
import { createI18n } from 'vue-i18n'
import antZh from 'ant-design-vue/lib/locale-provider/zh_CN'
import antEn from 'ant-design-vue/lib/locale-provider/en_US'
import antKmKh from 'ant-design-vue/lib/locale-provider/km_KH'
import antVivn from 'ant-design-vue/lib/locale-provider/vi_VN'
import antEs_ES from 'ant-design-vue/lib/locale-provider/es_ES'

import en from './en_us'
import zh from './zh_cn'
import kzc from './kzc'
import vivn from './vivn'
import eses from './eses'
 

export const languages = {
  'en_US': {
    ...en,
    ...antEn
  },
  'zh-cn': {
    ...zh,
    ...antZh 
  },
  'km_KH': {
    ...antKmKh,
    ...kzc
  },
  'vi_VN': {
    ...antVivn,
    ...vivn
  },
  'es_ES': {
    ...antEs_ES,
    ...eses

  }
}

export const getLanguage = () => { 
  const chooselang = localStorage.getItem('locale')
  return chooselang || 'zh-cn'
}


 const i18n = createI18n({
    legacy: false,
    locale: getLanguage(),
    fallbackLocale: 'zh-cn',
    global: true,
    messages: languages
})

export default i18n;
